10 REM RECTANGULAR HORN ANTENNA PROGRAM
20 REM "ANTENNA DESIGN USING PERSONAL COMPUTERS"
30 DIM A(12),B(12),C(12),D(12),F(91)
40 DATA 1.59577,3.3E-8,0,.199471,-1.702E-6,4.25539,-.0249339,2.3E-8,-6.80856
50 DATA -9.281E-5,3.936E-6,-9.35134E-3,-5.76361E-4,-7.78002,5.77096E-3
60 DATA 2.3006E-5,6.92069,-9.52089E-3,6.89892E-4,4.85146E-3,-.0168986
70 DATA 5.07516,-9.49714E-3,1.90322E-3,-3.05048,-.138342,.0119488,-.0171229
80 DATA -.0757524,-1.36373,-6.74887E-3,.029064,.850664,-.403349,2.4642E-4
90 DATA -.0279289,-.025639,.702222,2.10297E-3,.0164973,-.150231,-.216196
100 DATA -1.2173E-3,-5.59852E-3,.0344048,.019547,2.33939E-4,8.38386E-4
110 GOSUB 1180
120 PI=3.141593
130 ROD=PI/180
140 DEF FNLOG10(X)=.4343*LOG(X)
150 KEY OFF
160 SCREEN 0,1
170 CLS
180 COLOR 1,0
190 PRINT "RECTANGULAR HORN ANTENNA GAIN AND PATTERNS"
200 COLOR 4,0
210 PRINT
220 PRINT "SELECT OPTION:"
230 PRINT "               1- E-PLANE SECTORAL HORN ANALYSIS"
240 PRINT "               2- H-PLANE SECTORAL HORN ANALYSIS"
250 PRINT "               3- PYRAMIDAL HORN ANALYSIS"
260 PRINT "               4- PYRAMIDAL HORN DESIGN"
270 PRINT "               5- EXIT"
280 INPUT IOP
290 IF IOP<1 OR IOP>5 THEN GOTO 210
300 IF IOP=5 THEN GOTO 2960
310 CLS
320 COLOR 14,0
330 IF IOP=4 THEN GOTO 2600
340 IF IOP=1 THEN PRINT "E-PLANE SECTORAL HORN ANALYSIS"
350 IF IOP=2 THEN PRINT "H-PLANE SECTORAL HORN ANALYSIS"
360 IF IOP=3 THEN PRINT "PYRAMIDAL HORN ANALYSIS"
370 PRINT
380 COLOR 4,0
390 INPUT "WHAT IS THE FREQUENCY(MHz)";FMC
400 INPUT "WHAT IS THE E-PLANE APERTURE DIMENSION(meters)";AE
410 INPUT "WHAT IS THE H-PLANE APERTURE DIMENSION(meters)";AH
420 INPUT "WHAT IS THE HORN LENGTH (TO APEX)(meters)";R
430 COLOR 14,0
440 PRINT
450 WL=300/FMC
460 AEOL=AE/WL
470 AHOL=AH/WL
480 IF IOP=1 OR IOP=3 THEN GOSUB 1530
490 IF IOP=2 OR IOP=3 THEN GOSUB 1620
500 AEOP=SQR(2*WL*R)
510 AHOP=SQR(3*WL*R)
520 IF IOP=1 THEN PRINT USING "THE OPTIMUM E-PLANE DIMENSION IS #.### m";AEOP
530 IF IOP=2 THEN PRINT USING "THE OPTIMUM H-PLANE DIMENSION IS #.### m";AHOP
540 IF IOP=1 THEN DR=DE
550 IF IOP=2 THEN DR=DH
560 IF IOP=3 THEN DR=PI*WL*WL*DE*DH/(32*AE*AH)
570 DDB=10*FNLOG10(DR)
580 PRINT USING "THE DIRECTIVITY IS ###.# OR ##.# dB";DR,DDB
590 PRINT
600 COLOR 4,0
610 INPUT "PLOT PATTERNS(Y,N)";IS$
620 IF IS$="N" THEN GOTO 160
630 INPUT "E-PLANE(E), OR H-PLANE(H)";POP$
640 IF POP$="E" THEN GOTO 670
650 IF POP$="H" THEN GOTO 670
660 GOTO 630
670 IF IOP=1 AND POP$="E" THEN GOSUB 1790
680 IF IOP=1 AND POP$="H" THEN GOSUB 1990
690 IF IOP=2 AND POP$="E" THEN GOSUB 2110
700 IF IOP=2 AND POP$="H" THEN GOSUB 2200
710 IF IOP=3 AND POP$="E" THEN GOSUB 1790
720 IF IOP=3 AND POP$="H" THEN GOSUB 2200
730 SCREEN 0,1
740 CLS
750 REM CONVERT FIELD TO DB
760 FOR I=0 TO 90
770 IF F(I)<.0316 THEN F(I)=.0316
780 F(I)=20*FNLOG10(F(I))
790 NEXT I
800 REM COMPUTE BEAMWIDTH
810 TH=0
820 TH=TH+1
830 IF F(TH)>-3 THEN GOTO 820
840 TH0=(-3-F(TH-1)+(TH-1)*(F(TH)-F(TH-1)))/(F(TH)-F(TH-1))
850 BW=2*TH0
860 SCREEN 2,0
870 VIEW (262,9)-(638,187)
880 WINDOW (-2,-35)-(92,2)
890 FOR J=0 TO 90 STEP 10
900 LINE (J,-30)-(J,-30.6)
910 NEXT J
920 LINE (90,-30)-(0,-30)
930 FOR J=0 TO -30 STEP -1
940 PSET (-1,J)
950 IF INT(J/10)=J/10 THEN PSET (-2,J)
960 LINE -(0,J)
970 NEXT J
980 LINE (0,0)-(0,-30)
990 LOCATE 23,55
1000 PRINT "THETA"
1010 FOR I=0 TO 3
1020 LOCATE 3+6*I,30
1030 PRINT USING "###";-10*I
1040 NEXT I
1050 LOCATE 12,29: PRINT "dB"
1060 LOCATE 22,35
1070 PRINT "0   10   20   30   40   50   60   70   80   90"
1080 LOCATE 1,1
1090 IF POP$="E" THEN PRINT "E-PLANE"
1100 IF POP$="H" THEN PRINT "H-PLANE"
1110 PSET (0,0)
1120 FOR I=0 TO 90
1130 LINE -(I,F(I))
1140 NEXT I
1150 LOCATE 2,1
1160 PRINT USING "BEAMWIDTH=###.# deg.";BW
1170 GOTO 610
1180 REM SUBROUTINE FOR FRESNEL INTEGRALS
1190 REM INPUT XI, OUTPUT CX,SX
1200 FOR I=1 TO 12
1210 READ A(I),B(I),C(I),D(I)
1220 NEXT I
1230 RETURN
1240 REM ENTER HERE AFTER FIRST CALL TO READ IN DATA
1250 X=ABS(XI)
1260 X=PI*X*X/2
1270 FR=0
1280 FI=0
1290 K=13
1300 IF X>=4 THEN GOTO 1410
1310 Y=X/4
1320 K=K-1
1330 FR=(FR+A(K))*Y
1340 FI=(FI+B(K))*Y
1350 IF K>2 THEN GOTO 1320
1360 FR=FR+A(1)
1370 FI=FI+B(1)
1380 CX=(FR*COS(X)+FI*SIN(X))*SQR(Y)
1390 SX=(FR*SIN(X)-FI*COS(X))*SQR(Y)
1400 GOTO 1500
1410 Y=4/X
1420 K=K-1
1430 FR=(FR+C(K))*Y
1440 FI=(FI+D(K))*Y
1450 IF K>2 THEN GOTO 1420
1460 FR=FR+CC(1)
1470 FI=FI+D(1)
1480 CX=.5+(FR*COS(X)+FI*SIN(X))*SQR(Y)
1490 SX=.5+(FR*SIN(X)-FI*COS(X))*SQR(Y)
1500 IF XI<0 THEN CX=-CX
1510 IF XI<0 THEN SX=-SX
1520 RETURN
1530 REM PHASE ERROR AND GAIN FOR E-PLANE HORN
1540 SE=AE*AE/(8*WL*R)
1550 PE=SE*360
1560 Q=AE/SQR(2*WL*R)
1570 XI=Q
1580 GOSUB 1240
1590 DE=32*AH*AE*(CX*CX+SX*SX)/(PI*WL*WL*Q)
1600 PRINT USING "THE MAX. E-PLANE PHASE ERROR IS ###.# degrees";PE
1610 RETURN
1620 REM PHASE ERROR AND GAIN FOR H-PLANE HORN
1630 SH=AH*AH/(8*WL*R)
1640 PE=SH*360
1650 C1=SQR(R/WL)
1660 C2=AH/WL
1670 P1=.707*(C1/C2+C2/C1)
1680 P2=.707*(C1/C2-C2/C1)
1690 XI=P1
1700 GOSUB 1240
1710 C1=CX
1720 S1=SX
1730 XI=P2
1740 GOSUB 1240
1750 DH=(C1-CX)^2+(S1-SX)^2
1760 DH=DH*4*PI*AE*R/(WL*AH)
1770 PRINT USING "THE MAX. H-PLANE PHASE ERROR IS ###.# degrees";PE
1780 RETURN
1790 REM E-PLANE HORN, E-PLANE PATTERN
1800 S2S=2*SQR(SE)
1810 FOR I=0 TO 90
1820 TH=I*ROD
1830 STH=SIN(TH)
1840 C1=AEOL*STH/(4*SE)
1850 R3=S2S*(-1-C1)
1860 R4=S2S*(1-C1)
1870 XI=R3
1880 GOSUB 1240
1890 C1=CX
1900 S1=SX
1910 XI=R4
1920 GOSUB 1240
1930 FT=(CX-C1)^2+(SX-S1)^2
1940 XI=S2S
1950 GOSUB 1240
1960 F(I)=.25*(1+COS(TH))*SQR(FT/(CX*CX+SX*SX))
1970 NEXT I
1980 RETURN
1990 REM E-PLANE HORN, H-PLANE PATTERN
2000 C1=PI*AHOL
2010 C2=2*AHOL
2020 FOR I=0 TO 90
2030 TH=I*ROD
2040 STH=SIN(TH)
2050 DEN=1-(C2*STH)^2
2060 IF ABS(DEN)<.01 THEN FT=PI/4
2070 IF ABS(DEN)>=.01 THEN FT=COS(C1*STH)/DEN
2080 F(I)=.5*(1+COS(TH))*FT
2090 NEXT I
2100 RETURN
2110 REM H-PLANE HORN, E-PLANE PATTERN
2120 C1=AEOL*PI
2130 F(0)=1
2140 FOR I=1 TO 90
2150 TH=I*ROD
2160 STH=SIN(TH)
2170 F(I)=.5*(1+COS(TH))*SIN(C1*STH)/(C1*STH)
2180 NEXT I
2190 RETURN
2200 REM H-PLANE HORN, H-PLANE PATTERN
2210 S2S=2*SQR(SH)
2220 PO8T=PI/(8*SH)
2230 I0=1
2240 FOR I=0 TO 90
2250 TH=I*ROD
2260 STH=SIN(TH)
2270 C1=PO8T*(AHOL*STH+.5)^2
2280 ER1=COS(C1)
2290 EI1=SIN(C1)
2300 C1=PO8T*(AHOL*STH-.5)^2
2310 ER2=COS(C1)
2320 EI2=SIN(C1)
2330 C1=AHOL*STH/(4*SH)
2340 S1=S2S*(-1-C1-.125/SH)
2350 S2=S2S*(1-C1-.125/SH)
2360 T1=S2S*(-1-C1+.125/SH)
2370 T2=S2S*(1-C1+.125/SH)
2380 XI=S1
2390 GOSUB 1240
2400 C1=CX
2410 S1=SX
2420 XI=S2
2430 GOSUB 1240
2440 C2=CX
2450 S2=SX
2460 XI=T1
2470 GOSUB 1240
2480 C3=CX
2490 S3=SX
2500 XI=T2
2510 GOSUB 1240
2520 IR=ER1*(C2-C1)+EI1*(S2-S1)+ER2*(CX-C3)+EI2*(SX-S3)
2530 II=ER1*(S1-S2)+EI1*(C2-C1)+ER2*(S3-SX)+EI2*(CX-C3)
2540 IFF=SQR(IR*IR+II*II)
2550 F(I)=.5*(1+COS(TH))*IFF/I0
2560 IF I=0 THEN I0=IFF
2570 NEXT I
2580 F(0)=1
2590 RETURN
2600 REM PYRAMIDAL HORN DESIGN
2610 PRINT "OPTIMUM HORN DESIGN"
2620 PRINT
2630 COLOR 4,0
2640 INPUT "WHAT IS THE DESIRED GAIN(dB)";GDB
2650 G=10^(GDB/10)
2660 INPUT "WHAT IS THE FREQUENCY(MHz)";FMC
2670 INPUT "WHAT IS THE H-PLANE WAVEGUIDE DIMENSION(meters)";AW
2680 INPUT "WHAT IS THE E-PLANE WAVEGUIDE DIMENSION(meters)";BW
2690 COLOR 14,0
2700 REM SOLVE FOR SIG
2710 WL=300/FMC
2720 SIG=(G/15.4)/1.3
2730 DSIG=SIG/100
2740 FTO=0
2750 FT=(G/(8.885801*SQR(SIG))-AW/WL)^2*(G*G/(177.65*SIG)-1)
2760 FT=FT-(2*SIG-1)*(SQR(2*SIG)-BW/WL)^2
2770 IF FT*FTO<0 THEN GOTO 2820
2780 SIG=SIG+DSIG
2790 IF SIG>G/7 THEN GOTO 2950
2800 FTO=FT
2810 GOTO 2750
2820 SIG=SIG-DSIG/2
2830 AE=SQR(2*SIG)*WL
2840 AH=G*WL*WL/(2*PI*AE)
2850 R=(AE-BW)*SQR((SIG*WL/AE)^2-.25)
2860 PRINT
2870 PRINT USING "E-PLANE APERTURE DIMENSION=##.### meters";AE
2880 PRINT USING "H-PLANE APERTURE DIMENSION=##.### meters";AH
2890 PRINT USING "RADIUS TO APEX=##.### meters";R
2900 PRINT
2910 COLOR 4,0
2920 INPUT "CONTINUE(Y,N)";POP$
2930 IF POP$="N" THEN GOTO 2960
2940 GOTO 160
2950 PRINT "ERROR IN FINDING SIG ROOT."
2960 SCREEN 0,1
2970 COLOR 7,0
2980 KEY ON
2990 END
